import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.FileReader;
import java.io.IOException;
import java.util.List;

public class NumberFour {


    public static void main(String[] args) {
        try (
                FileReader fileReader=new FileReader("dome4_1/src/books.xml")
                ){
            Document read = new SAXReader().read(fileReader);
            Element rootElement = read.getRootElement();
            List<Element> book = rootElement.elements("book");
            for (Element element : book) {
                System.out.println(element.elementText("name"));
                System.out.println(element.elementText("press"));
                System.out.println(element.elementText("publication_date"));
                System.out.println(element.elementText("price"));
            }
        }catch (IOException e){
            e.printStackTrace();
        } catch (DocumentException e) {
            throw new RuntimeException(e);
        }

    }
}
